<?php

/*
|--------------------------------------------------------------------------
| Web Routes
|--------------------------------------------------------------------------
|
| Here is where you can register web routes for your application. These
| routes are loaded by the RouteServiceProvider within a group which
| contains the "web" middleware group. Now create something great!
|
*/

Route::get('/', 'TopicsController@index')->name('root');
Route::get('permission-denied', 'PagesController@permissionDenied')->name('permission-denied');

/*---------------------------------------*/
/*--------     1. Auth相关        --------*/
/*---------------------------------------*/
Auth::routes();

/*---------------------------------------*/
/*--------     2. 用户相关        --------*/
/*---------------------------------------*/
// show GET /users/{user} 显示用户个人信息
// edit GET /users/{user}/edit 显示编辑个人资料页面
//update PATCH /users/{user} 处理edit页面提交的更改
Route::resource('users','UsersController',['only'=>['show','update','edit']]);
Route::post('/users/followers/{user}', 'FollowersController@store')->name('followers.store');//关注用户
Route::delete('/users/followers/{user}', 'FollowersController@destroy')->name('followers.destroy');//取消关注
/*---------------------------------------*/
/*--------     3. 话题相关        --------*/
/*---------------------------------------*/
// show GET /users/{user} 显示用户个人信息
// edit GET /users/{user}/edit 显示编辑个人资料页面
//update PATCH /users/{user} 处理edit页面提交的更改
Route::resource('topics', 'TopicsController', ['only' => ['index', 'create', 'store', 'update', 'edit', 'destroy']]);
Route::get('topics/{topic}/{slug?}', 'TopicsController@show')->name('topics.show');

Route::post('upload_image', 'TopicsController@uploadImage')->name('topics.upload_image');//上传图片
/*---------------------------------------*/
/*--------     4. 分类相关        --------*/
/*---------------------------------------*/
Route::resource('categories','CategoriesController',['only'=>['show']]);

/*---------------------------------------*/
/*--------     4. 回复相关        --------*/
/*---------------------------------------*/
Route::resource('replies', 'RepliesController', ['only' => ['store', 'destroy']]);